package com.tansun.rule.config;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.tansun.rule.pojo.EnterPoint;
import com.tansun.rule.pojo.RuleProj;
import com.tansun.rule.sessionPool.SessionPool;
import com.tansun.rule.utils.MClass;
import com.tansun.ruledata.data.entity.DeployReferenceData;
import com.tansun.ruledata.sessionpool.SessionDataPool;

public class AppConfiguration {
	
	/**应用目录 have to init*/
	public static String APPHOMEDIR;
	public static String isNeedLog = "0";
	public static String isRedisEnable = "1";
	public static String RuleProjDeployDir = "RuleProjects";
	
	/**规则项目设置*/
	public static final String RuleProjConf = "RuleObject.conf";
	
	/**项目Map key:项目名称 have to init*/
	public static Map<String, RuleProj> RuleProjMap = new HashMap<String, RuleProj>();
	
	//数据库版本入口点Map
	public  static  Map<String,Map<String,EnterPoint>>  ruleEnterMap = new HashMap<>();
	//数据库版本部署文件
	public  static  Map<String,List<String>>  deployDrlList = new  HashMap<>();
	
	/**系统转换映射 have to init*/
	public static Map<String, Map<String, MClass>> RuleProjMetaMap = new HashMap<String, Map<String, MClass>>();
	/***规则流使用参数映射******/
	public static Map<String, Map<String, MClass>> RuleFlowMetaMap = new HashMap<String, Map<String, MClass>>();
	
	
	public  static  Map<String,Map<String,String>>  ruleRefMap  = new  HashMap<String,Map<String,String>>();
	
	public  static  Map<String,String>  funcMap   = new  HashMap<>();
	
	/**每个规则项目对应个session池 在第一次调用时更新，不再初始化*/
	public static Map<String, SessionPool> AppRuleProjPools = new HashMap<String, SessionPool>();
	/**每个规则项目对应个session池 在第一次调用时更新，不再初始化*/
	public static Map<String, SessionDataPool> AppRuleProjDataPools = new HashMap<String, SessionDataPool>();
	/**日终跑批*/
	public static Map<String, SessionDataPool> AppRuleProjDataPoolsForJob = new HashMap<String, SessionDataPool>();
	/**冠军挑战者信息*/
	public static Map<String, String> AppRuleProjChampionChallengerInfo = new HashMap<String, String>();
	
	/**PMML缓存信息，缓存对应关系变量******/
	public static Map<String,Map<String,Map<String, DeployReferenceData>>> PmmlRefParamMap = new HashMap<>();
	/**PMML缓存信息，缓存PMML******/
	public static Map<String,Map<String,String>> PmmlMap = new HashMap<>();
	/** 判断数据是否完备**/
	public  static  Map<String, Boolean> DataPerfect = new HashMap<>();
	
	public  static  Map<String,String>  dateTimeMap  = new  HashMap<>();
	
	
	/**部署文件名*/
	public static final String JarFile = "RulePackage.jar";
	public static final String BomFile = "RuleBomMapping.xml";
	public static final String DepFile = "RuleDeploy.xml";
	
	/**session 个数*/
	public static final int InitMaxTotal = 10;
	public static final int InitMaxIdle = 5;
	
	public static final SimpleDateFormat LongSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	
	public static String getRuleflowId(String ruleProjName, String enterPointCode){
		RuleProj rp = RuleProjMap.get(ruleProjName);
		for (EnterPoint ep : rp.getEnterPointList()) {
			if(ep.getCode().equals(enterPointCode)){
				return ep.getRuleflowId();
			}
			
		}
		return null;
	}
	
}